package com.wontube.smr.bo.sites.fs.api;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.wontube.smr.bo.sites.fs.conf.FourShared;


public final class SimpleAPI extends FSAPI {
	public String getDirectLink(String link) {
		String method = "getDirectLink";
		String[] args = new String[] { 
				FourShared.fs.getUsername(),
				FourShared.fs.getPassword(), 
				link };

		Document doc = super.invoke(method, args);
		NodeList list = doc.getElementsByTagName("return");

		if (list.getLength() > 0) {
			Node node = list.item(0).getFirstChild();
			if (node != null) {
				String value = node.getNodeValue();
				if (value != null && value.startsWith("http://")) {
					return value;
				}
			}
		}
		return link;
	}
}
